﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发布动态</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <link href="https://cdn.bootcss.com/amazeui/2.7.2/css/amazeui.css" rel="stylesheet">
    <style>
        textarea {
            width: 100%;
            border: none;
            padding-left: 2%;
            resize: none;
        }

        .main {
            width: 100%;
            padding: 2%;
        }

        .uploadPic {
            width: 100%;
        }

        .uploadactive {
            width: 31%;
            max-width: 120px;
            max-height: 120px;
            position: relative;
            height: 120px;
            float: left;
            margin: 1%;
        }

            .uploadactive img, .uploadactive input {
                width: 100%;
                display: block;
                position: absolute;
                top: 0;
            }

        .close {
            display: block;
            position: absolute;
            right: 5%;
            top: 0%;
            color: #6fddb1;
            font-size: 1.6rem;
        }
    </style>
</head>
<body>
    <div id="page">
        <header data-am-widget="header" class="am-header am-header-default" style="background-color: #FFFFFF; border-bottom: 1px solid rgb(211, 211, 211);">
            <div class="am-header-left am-header-nav" onclick="goBack()">
                <a href="javascript:" class="">
                    <img class="am-header-icon-custom" src="images/veas07.png" alt="" />
                </a>
            </div>
            <h4 class="am-header-title" style=" color: black;">发布</h4>
            <div class="am-header-right am-header-nav"><a href="/Wap/Index.html" class="am-header-icon am-icon-home" style="color: #A9A9A9; "></a></div>
        </header>
        <div class="main">
            <textarea class="" rows="6" id="doc-ta-1" v-model="profile"  placeholder="你想说点什么？"></textarea>
            <!--<div class="uploadPic">
                <div class="uploadactive">
                    <img src="images/uploadpic.png" alt="">
                    <input type="file" style="height: 120px;opacity: 0">
                </div>
                <div class="uploadactive">
                    <img src="" alt="">
                    <span class="am-icon am-icon-times-circle close"></span>
                </div>
            </div>-->
            <div class="am-form-group">
                <label for="doc-ipt-file-1">点击上传照片</label>
                <input type="hidden" readonly v-model="faceImg" name="faceImg">

                <label>
                    <input type="file" id="doc-ipt-file-1" onchange="upload()" multiple name="file" class="am-btn am-btn-default am-btn-sm" style="display:none">
                    <img v-bind:src="faceImg.length>0 ? faceImg : 'images/nouserfaceimg.png'" style="width:50px;height:50px;" />
                </label>
            </div>
        </div>
        <button class="am-btn" style="background: #6fddb1;color: #fff;width: 100%;position: fixed;bottom: 0;padding: 3% 0;left: 0;" v-on:click="tijiao()">发布</button>
    </div>
</body>
</html>
<script src="https://cdn.bootcss.com/jquery/1.8.3/jquery.js"></script>
<script src="https://cdn.bootcss.com/vue/2.5.9/vue.js"></script>
<script src="https://cdn.bootcss.com/amazeui/2.7.2/js/amazeui.js"></script>
<script src="js/common.js"></script>
<script src="http://file.jiaoxin-tech.cn/help/js/upyun.js"></script>
<script>
    //$(function () {
    //    $('.close').click(function () {
    //        $(this).parent().hide();
    //    })
    //})

    var page = new Vue({
        el: '#page',
        data: {
            faceImg: "",
            profile:""
        },
        methods: {
            tijiao: function () {
                var that = this;
                $.ajax({
                    type: 'POST',
                    url: window.apiUrl + '/Api/Field/AddTrainDynamic',
                    data: { Img: that.faceImg, profile: that.profile,gId : $.getParam("gId") },
                    success: function (data) {
                        console.log(data);
                        if (data.errcode == 0) {
                            alert(data.errmsg, function () {
                                location.href = "TrainSignInfo.html?venueid" + $.getParam("gId");
                            });
                            //console.log(that.userinfo)
                        } else {
                            alert(data.errmsg);
                        }
                    },
                    //error: function () {
                    //    alert("服务器加载异常");
                    //}
                })
            }
        }
    })

    var filebase = "http://file.jiaoxin-tech.cn";
    var upyun = new Upyun({
        bucket: 'topman-upyun',//'topman-upyun',
        operator: 'admin',
        getSignatureUrl: 'https://xcx.egaopa.com/Api/upyun/index',
        opts: {
            'notify-url': 'http://feiyu.test.jiaoxin-tech.cn/Api/test/upyun',
            //'x-gmkerl-thumb':'/quality/75',//压缩,只能上传图片类型
            //'content-secret':'zhangsan',//文件密钥，用于保护文件，防止文件被直接访问
            //'allow-file-type':'jpg,jpeg,png',//允许上传的文件扩展名，以 , 分隔
            //'content-length-range':'',//文件大小限制，格式：min,max，单位：字节 如 102400,1024000，表示允许上传 100Kb～1Mb 的文件
            //'ext-param':'',//自定义参数,回调时带回
            //'b64encoded':'on',//base64解码
        }
    })

    function upload() {
        if (document.getElementById("doc-ipt-file-1").files.length > 0) {
            for (var n = 0; n < document.getElementById("doc-ipt-file-1").files.length; n++) {
                upyun.upload({
                    localPath: document.getElementById("doc-ipt-file-1").files[n],
                    remotePath: '/feiyu/{filemd5}{.suffix}',
                    success: function (res) {
                        alert('上传成功');
                        page.faceImg = filebase + res.url;
                        console.log('上传成功:', res)
                    }, error: function (err) {
                        alert("上传失败:" + err.message);
                    }, complete: function (xhr) {
                        console.log("上传操作结束:", xhr);
                    }, progress: function (e) {
                   }
                })
            }
        }
    }
    </script>
